package fitness;

import org.jgap.FitnessFunction;
import org.jgap.IChromosome;

import character.Druid;

public class DruidFitness extends FitnessFunction {

	/**
	 * 
	 */
	private static final long serialVersionUID = 7540611915325633532L;

	@Override
	protected double evaluate(IChromosome profile) {

		Integer strength = (Integer) profile.getGene(0).getAllele();
		Integer agility =  (Integer) profile.getGene(1).getAllele();
		Integer stamina =  (Integer) profile.getGene(2).getAllele();
		Integer intellect =  (Integer) profile.getGene(3).getAllele();
		Integer spirit =  (Integer) profile.getGene(4).getAllele();
		
		Druid druid = new Druid();
		druid.setStrength(strength);
		druid.setAgility(agility);
		druid.setStamina(stamina);
		druid.setIntellect(intellect);
		druid.setSpirit(spirit);
		
		double res = 5.882  * druid.getAttackPower() +
					 8.824  * druid.getArmor() + 
					 5.882  * druid.getSpeed() +
					 2.941  * druid.getResilience() + 
					 1.471 * druid.getDodgeRating() + 
					 2.353 * druid.getMana() +
					 2.059 * druid.getHealth() +
					 23.529  * druid.getSpellPenetration() +
					 17.647  * druid.getHaste() + 
					 11.765  * druid.getHealthRegeneration() +
					 17.647  * druid.getManaRegeneration();
		return res;
	}

}
